package com.pushway.demo.service;

import com.pushway.demo.pojo.CounterPushItem;
import com.pushway.demo.pojo.GuagePushItem;
import com.pushway.demo.pojo.SummaryPushItem;

import java.io.IOException;
import java.util.Arrays;

public class PushGatewayTest {

    public static void main(String[] args) throws IOException {
        String pushGatewayHost = "10.122.30.61:9091";
        PushGatewayService pushGatewayService = new PushGatewayService();
        pushGatewayService.init(pushGatewayHost);

        CounterPushItem counter = new CounterPushItem("my_instance", "push-gateway-demo", "exception", "异常统计", Arrays.asList("type"));
        counter.labels("fail").inc();
        counter.labels( "error").inc();
        pushGatewayService.push(counter);


        GuagePushItem guage = new GuagePushItem("my_instance", "push-gateway-demo", "exception_count", "异常数量", Arrays.asList("type"));
        guage.labels("fail").set(25);
        guage.labels( "error").inc();
        pushGatewayService.push(guage);


        SummaryPushItem summary = new SummaryPushItem("my_instance", "push-gateway-demo", "data_status", "数据抛帐情况", Arrays.asList("type"));
        summary.labels("success").observe(10);
        summary.labels("fail").observe(1);
        summary.labels( "error").observe(5);
        pushGatewayService.push(summary);

        SummaryPushItem summary2 = new SummaryPushItem("my_instance", "push-gateway-demo", "posting_status", "数据抛帐情况", Arrays.asList("type"));
        summary2.labels("success").observe(10);
        summary2.labels("fail").observe(1);
        summary2.labels( "error").observe(5);
        pushGatewayService.push(summary2);
    }

}